package demo01;

class Printer {
    private boolean printNumber = true; 
    public synchronized void printnumbers() throws InterruptedException {
        for (int i = 1; i <= 52; i++) {
            while (!printNumber) { 
                wait();
            }
            System.out.print(i);
            if (i % 2 == 0) { 
                printNumber = false;
                notifyAll();
            }
        }
    }

    public synchronized void printLetters() throws InterruptedException {
        for (char c = 'A'; c <= 'Z'; c++) {
            while (printNumber) {
                wait();
            }
            System.out.print(c);
            printNumber = true; 
            notifyAll();
        }
    }
}
